<template>
  <div class="content">
    <dt-search ref="search" :label-width="80">
      <Button type="primary" v-if="unlocking('0207050901')" @click="onExport">导出</Button>
    </dt-search>

    <dt-grid ref="table" page :onFetch="onFetch" />
  </div>
</template>

<script>
  import moment from 'moment'
  import Column from './opt/Column.js'
  import SearchOpt from './opt/SearchOpt.js'
  import mgr from './biz'

  export default {
    data() {
      return {
        search: {
          bonusStartMonth: moment().format('YYYY-MM'),
          bonusEndMonth: moment().format('YYYY-MM')
        }
      }
    },
    mounted() {
      this.$refs.table.init(this, new Column())
      this.$refs.search.init(this.$refs.table, new SearchOpt(this.search), this.search)
      this.$refs.table.fetch()
    },
    methods: {
      onFetch(data) {
        this.search = data
        return mgr.list(data)
      },
      onExport() {
        mgr.exportList(this.search)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .content {
    padding: 20px;
  }

  .statistics {
    display: flex;
    .item {
      margin-right: 12px;
      padding: 1px 5px;
      border-radius: 2px;
      color: #fa795e;
      background-color: #fff5f5;
      display: flex;
      align-items: center;
      p {
        margin-left: 3px;
      }
    }
  }
</style>
